# Update memcache after the commit
$that->invalidateCache();
+ $updateLogPage = false;
if ( $newPageContent ) {
# New file page; create the description page.
# There's already a log entry, so don't make a second RC entry
if ( isset( $status->value['revision'] ) ) {
/** @var $rev Revision */
$rev = $status->value['revision'];
- $that->getRepo()->getMasterDB()->update(
- 'logging',
- array( 'log_page' => $rev->getPage() ),
- array( 'log_id' => $logId ),
- __METHOD__
- );
+ $updateLogPage = $rev->getPage();
}
} else {
# Existing file page: invalidate description page cache
Article::purgePatrolFooterCache( $descId );
}
- # Now that the page exists, make an RC entry.
+ # Update associated rev id. This should be done by $logEntry->insert() earlier,
+ # but setAssociatedRevId() wasn't called at that point yet...
+ $logParams = $logEntry->getParameters();
+ $logParams['associated_rev_id'] = $logEntry->getAssociatedRevId();
+ $update = array( 'log_params' => LogEntryBase::makeParamBlob( $logParams ) );
+ if ( $updateLogPage ) {
+ # Also log page, in case where we just created it above
+ $update['log_page'] = $updateLogPage;
+ }
+ $that->getRepo()->getMasterDB()->update(
+ 'logging',
+ $update,
+ array( 'log_id' => $logId ),
+ __METHOD__
+ );
+ $that->getRepo()->getMasterDB()->insert(
+ 'log_search',
+ array(
+ 'ls_field' => 'associated_rev_id',
+ 'ls_value' => $logEntry->getAssociatedRevId(),
+ 'ls_log_id' => $logId,
+ ),
+ __METHOD__
+ );
+
+ # Now that the log entry is up-to-date, make an RC entry.
$logEntry->publish( $logId );
# Run hook for other updates (typically more cache purging)
Hooks::run( 'FileUpload', array( $that, $reupload, !$newPageContent ) );
/** @var User */
protected $performer;
+ /** @var array Parameters for log entry */
+ protected $params;
+
+ /** @var int A rev id associated to the log entry */
+ protected $revId = null;
+
/** @var bool Whether the parameters for this log entry are stored in new or old format. */
protected $legacy;
}
public function isLegacy() {
- // This does the check
+ // This extracts the property
$this->getParameters();
return $this->legacy;
}
$this->params = LogPage::extractParams( $blob );
$this->legacy = true;
}
+
+ if ( isset( $this->params['associated_rev_id'] ) ) {
+ $this->revId = $this->params['associated_rev_id'];
+ unset( $this->params['associated_rev_id'] );
+ }
}
return $this->params;
}
+ public function getAssociatedRevId() {
+ // This extracts the property
+ $this->getParameters();
+ return $this->revId;
+ }
+
public function getPerformer() {
if ( !$this->performer ) {
$userId = (int)$this->row->log_user;
return $this->row->rc_params;
}
+ public function getAssociatedRevId() {
+ return $this->row->rc_this_oldid;
+ }
+
public function getType() {
return $this->row->rc_log_type;
}
// Truncate for whole multibyte characters.
$comment = $wgContLang->truncate( $comment, 255 );
+ $params = $this->getParameters();
+ $relations = $this->relations;
+
+ // Additional fields for which there's no space in the database table schema
+ $revId = $this->getAssociatedRevId();
+ if ( $revId ) {
+ $params['associated_rev_id'] = $revId;
+ $relations['associated_rev_id'] = $revId;
+ }
+
$data = array(
'log_id' => $id,
'log_type' => $this->getType(),
'log_title' => $this->getTarget()->getDBkey(),
'log_page' => $this->getTarget()->getArticleID(),
'log_comment' => $comment,
- 'log_params' => LogEntryBase::makeParamBlob( $this->getParameters() ),
+ 'log_params' => LogEntryBase::makeParamBlob( $params ),
);
if ( isset( $this->deleted ) ) {
$data['log_deleted'] = $this->deleted;
$this->id = !is_null( $id ) ? $id : $dbw->insertId();
$rows = array();
- foreach ( $this->relations as $tag => $values ) {
+ foreach ( $relations as $tag => $values ) {
if ( !strlen( $tag ) ) {
throw new MWException( "Got empty log search tag." );
}